import java.io.*;
import java.util.*;
/* here thr data encapsulation plus inhertance is implemented 
	making data variable and member function public ,private,protected
*/

/* this class take student info like name rno */
class StudentInfo
{
	private int Rno;
	private String Name;
	 void Getdata()
	{
		Scanner sobj = new Scanner(System.in);
		System.out.print("\n Enter the Roll No of Student :");
		Rno=sobj.nextInt();
		System.out.print("\n Enter the Name of Student    :");
		Name=sobj.next();
	}
	public void Putdata()
	{
		System.out.print("\n "+Rno);
		System.out.print("     "+Name); 
	}

}

/* this class inherites the stduent class and also take info of mark*/
class StudentMark extends StudentInfo
{
	protected int sub1,sub2,sub3,total;
	protected  float perce;
	
	protected void GetMark()
	{
		Scanner sobj = new Scanner(System.in);
		System.out.print("\n Enter the Mark of Sub1 :");
		sub1=sobj.nextInt();		
		System.out.print("\n Enter the Mark of Sub2 :");
		sub2=sobj.nextInt();		
		System.out.print("\n Enter the Mark of Sub3 :");
		sub3=sobj.nextInt();	
	}
	public void PutMark()
	{
		
		System.out.print("    "+sub1);
		System.out.print("   "+sub2);
		System.out.print("   "+ sub3);
		
	}
}
/*
this class inherits the stduent mark class and calulate percentage ,pass/fail result
*/
class result extends StudentMark
{
	
	String result;
	public void CalculateResult()
	{
		total=sub1+sub2+sub3;
		perce=total/3;
		if(sub1>=40 && sub2>=40 && sub3>=40)
			result="pass";
		else
			result="fail";
	System.out.print("   "+total);
	System.out.print("   "+perce);
	System.out.println("  "+result);
	}
}

public class Student extends StudentMark 
{
	
	public static void main(String args[])
	{	
		int i,noofstud;
		Scanner s = new Scanner(System.in);
		System.out.println("Enter How many Student :");
		noofstud=s.nextInt();
		try
		{
			result objstudent[] = new result[10];
			System.out.print("\n Enter the information of student :");
			for(i=0;i<noofstud;i++)
			{
				objstudent[i]=new result();
				objstudent[i].Getdata();
				objstudent[i].GetMark();
			}
			
			System.out.print("\n Rollno   Name  Sub1  sub2  sub3  Total  Percentage\n");
			for(i=0;i<noofstud;i++)
			{
				objstudent[i].Putdata();
				objstudent[i].PutMark();
				objstudent[i].CalculateResult();
			}
			
		System.out.println();
		}
		
		catch(Exception e)
		{
			System.out.println("exception caught.....");
		}

	}
}

		

